Release 10.1A: OpenEdge Data Management:
SQL Reference
CREATE SEQUENCE
A sequence is an object for creating an incremental number series. Sequences can generate sequential values within any integer range with either positive or negative increments. The database holds the sequence definition and keeps track of the next available value.
Use the following syntax to generate a sequence:
schema_nameSpecifies the schema to contain the sequence. If schema_name is not specified, the sequence generator creates the sequence in the current schema.
Note: Currently, OpenEdge supports only the PUBLIC (PUB) schema.sequence_nameSpecifies the name of the sequence to be created.
INCREMENT BYSpecifies the interval between sequence numbers. The value can be any positive or negative integer, but cannot be 0. When the value is positive, the sequence ascends. If it is negative, the sequence descends. The default value is 1.
START WITHSpecifies the first sequence number generated. In an ascending sequence, the value must be greater than or equal to the
MINVALUE. In a descending sequence, the value must be greater than or equal to theMAXVALUE. For ascending sequences, the default value isMINVALUE. For descending sequences, the default value isMAXVALUE.MAXVALUESpecifies the maximum value for the sequence to generate. For an ascending sequence, the default value is 2,147,483,647. For a descending sequence, the default value is -1.
NOMAXVALUESpecifies -1 as the
MAXVALUEfor descending sequences and 2,147,483,647 as theMAXVALUEfor ascending sequences.MINVALUESpecifies the minimum value the sequence can generate. For an ascending sequence, the default value is 0. For a descending sequence, the default value is -2,147,483,648.
NOMINVALUESpecifies 0 as the
MINVALUEfor ascending sequences and -2,147,483,648 as theMINVALUEfor descending sequences.CYLCEIndicates that the sequence will continue to generate values after reaching the value assigned to
MAXVALUE(if sequence ascends)orMINVALUE(if sequence descends).NOCYCLEIndicates that the sequence cannot generate more values after reaching the value assigned to
MAXVALUE(if sequence ascends) orMINVALUE(if sequence descends). The SQL-92 sequence generator usesNOCYCLEas the default ifCYCLEis not specified.In the following example, a sequence is used to generate unique customer numbers when a new customer is inserted into the table
Examplepub.customer:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |